package com.hydl.power.service.impl;

import com.hydl.power.mapper.AlarmSetMapper;
import com.hydl.power.pojo.AlarmSet;
import com.hydl.power.service.AlarmSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wxb
 * @date 2020/4/17 15:32
 */
@Service
public class AlarmSetServiceImpl implements AlarmSetService {

    @Autowired
    private AlarmSetMapper alarmSetMapper;

    @Override
    public AlarmSet selectBydeviceId(String deviceId) {
        return alarmSetMapper.selectBydeviceId(deviceId);
    }

    @Override
    public int updateAlarmSetUab(String deviceId,Integer uabClass,String uabBeginValue,String uabEndValue,Integer uabFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setUabClass(uabClass);
        alarmSet.setUabBeginValue(uabBeginValue);
        alarmSet.setUabEndValue(uabEndValue);
        alarmSet.setUabFlag(uabFlag);
        alarmSet.setUabTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetUbc(String deviceId, Integer ubcClass, String ubcBeginValue, String ubcEndValue, Integer ubcFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setUbcClass(ubcClass);
        alarmSet.setUbcBeginValue(ubcBeginValue);
        alarmSet.setUbcEndValue(ubcEndValue);
        alarmSet.setUbcFlag(ubcFlag);
        alarmSet.setUbcTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetUca(String deviceId, Integer ucaClass, String ucaBeginValue, String ucaEndValue, Integer ucaFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setUcaClass(ucaClass);
        alarmSet.setUcaBeginValue(ucaBeginValue);
        alarmSet.setUcaEndValue(ucaEndValue);
        alarmSet.setUcaFlag(ucaFlag);
        alarmSet.setUcaTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetPhaseA(String deviceId, Integer phaseAClass, String phaseABeginValue, String phaseAEndValue, Integer phaseAFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setPhaseAClass(phaseAClass);
        alarmSet.setPhaseABeginValue(phaseABeginValue);
        alarmSet.setPhaseAEndValue(phaseAEndValue);
        alarmSet.setPhaseAFlag(phaseAFlag);
        alarmSet.setPhaseATime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetPhaseB(String deviceId, Integer phaseBClass, String phaseBBeginValue, String phaseBEndValue, Integer phaseBFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setPhaseBClass(phaseBClass);
        alarmSet.setPhaseBBeginValue(phaseBBeginValue);
        alarmSet.setPhaseBEndValue(phaseBEndValue);
        alarmSet.setPhaseBFlag(phaseBFlag);
        alarmSet.setPhaseBTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetPhaseC(String deviceId, Integer phaseCClass, String phaseCBeginValue, String phaseCEndValue, Integer phaseCFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setPhaseCClass(phaseCClass);
        alarmSet.setPhaseCBeginValue(phaseCBeginValue);
        alarmSet.setPhaseCEndValue(phaseCEndValue);
        alarmSet.setPhaseCFlag(phaseCFlag);
        alarmSet.setPhaseCTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricityA(String deviceId, Integer electricityAClass, String electricityABeginValue, String electricityAEndValue, Integer electricityAFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricityAClass(electricityAClass);
        alarmSet.setElectricityABeginValue(electricityABeginValue);
        alarmSet.setElectricityAEndValue(electricityAEndValue);
        alarmSet.setElectricityAFlag(electricityAFlag);
        alarmSet.setElectricityATime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricityB(String deviceId, Integer electricityBClass, String electricityBBeginValue, String electricityBEndValue, Integer electricityBFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricityBClass(electricityBClass);
        alarmSet.setElectricityBBeginValue(electricityBBeginValue);
        alarmSet.setElectricityBEndValue(electricityBEndValue);
        alarmSet.setElectricityBFlag(electricityBFlag);
        alarmSet.setElectricityBTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricityC(String deviceId, Integer electricityCClass, String electricityCBeginValue, String electricityCEndValue, Integer electricityCFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricityCClass(electricityCClass);
        alarmSet.setElectricityCBeginValue(electricityCBeginValue);
        alarmSet.setElectricityCEndValue(electricityCEndValue);
        alarmSet.setElectricityCFlag(electricityCFlag);
        alarmSet.setElectricityCTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricA(String deviceId, Integer electricAClass, String electricABeginValue, String electricAEndValue, Integer electricAFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricAClass(electricAClass);
        alarmSet.setElectricABeginValue(electricABeginValue);
        alarmSet.setElectricAEndValue(electricAEndValue);
        alarmSet.setElectricAFlag(electricAFlag);
        alarmSet.setElectricATime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricB(String deviceId, Integer electricBClass, String electricBBeginValue, String electricBEndValue, Integer electricBFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricBClass(electricBClass);
        alarmSet.setElectricBBeginValue(electricBBeginValue);
        alarmSet.setElectricBEndValue(electricBEndValue);
        alarmSet.setElectricBFlag(electricBFlag);
        alarmSet.setElectricBTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetElectricC(String deviceId, Integer electricCClass, String electricCBeginValue, String electricCEndValue, Integer electricCFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setElectricCClass(electricCClass);
        alarmSet.setElectricCBeginValue(electricCBeginValue);
        alarmSet.setElectricCEndValue(electricCEndValue);
        alarmSet.setElectricCFlag(electricCFlag);
        alarmSet.setElectricCTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetDi(String deviceId, Integer diClass, Integer diFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setDiClass(diClass);
        alarmSet.setDiFlag(diFlag);
        alarmSet.setDiTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }

    @Override
    public int updateAlarmSetCommunication(String deviceId, Integer communicationClass, Integer communicationFlag) {
        AlarmSet alarmSet = alarmSetMapper.selectBydeviceId(deviceId);
        alarmSet.setCommunicationClass(communicationClass);
        alarmSet.setCommunicationFlag(communicationFlag);
        alarmSet.setCommunicationTime(System.currentTimeMillis());
        return alarmSetMapper.updateByDeviceId(alarmSet);
    }
}
